package sample;

import javafx.animation.FadeTransition;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.util.Duration;
import sample.util.Alert;
import sample.util.ButtonGenerator;


import java.net.MalformedURLException;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @name      :Main

 * @Description: main class for JavaFx application


*/
public class Main extends Application {

    @Override
    public void start(Stage primaryStage) {
//        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        //todo failed to set start animation
//        AtomicBoolean show=new AtomicBoolean(false);
//        ImageView iv= null;
//        try {
//            iv = new ImageView(ButtonGenerator.ImageGenerator("trophy"));
//        } catch (MalformedURLException ignored) {}
//        ImageView finalIv = iv;
//        Timeline tl=new Timeline(new KeyFrame(Duration.millis(5000), e->{
//            if(show.get()){
//                try {
//                    primaryStage.setScene(SceneBuilder.MainScene());
//                } catch (MalformedURLException ignored) {}
//                primaryStage.show();
//            }else{
////                primaryStage.setScene(new Scene(new Pane(finalIv)));
////                primaryStage.show();
//                new Alert("engining!",4,new Scene(new Pane(finalIv))).show();
//                show.set(true);
//            }
//        }));
//        tl.setCycleCount(2);
//        tl.play();
        try {
            primaryStage.setScene(SceneBuilder.MainScene());
        } catch (MalformedURLException ignored) {}
        primaryStage.setTitle("RelaxBox");
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
